{include file="public/base" /}
{block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑公告</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form method="get" action="javascript:;" class="form-horizontal">
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">订单编号</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="order_number" value="{$data.order_number}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">用户id</label>
                            <div class="col-sm-10" >
                                <input type="text" class="form-control" name="nickname" value="{$data.nickname}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商品id</label>
                            <div class="col-sm-10" >
                                <input type="text" class="form-control" name="commodity_id" value="{$data.commodity_id}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商品名称</label>
                            <div class="col-sm-10" >
                                <input type="text" class="form-control" name="name" value="{$data.name}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商品规格</label>
                            <div class="col-sm-10" >
                                <input type="text" class="form-control" name="specification" value="{$data.specification}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商品价格</label>
                            <div class="col-sm-10" >
                                <input type="text" class="form-control" name="price" value="{$data.price}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">订单状态</label>
                            <div class="col-sm-10" >
                                <select name="status">
                                    <option value="0">待支付</option>
                                    <option value="1">已支付</option>
                                    <option value="2">已发货</option>
                                    <option value="3">已完成</option>
                                    <option value="4">等待申诉</option>
                                    <option value="5">申诉成功</option>
                                    <option value="6">申诉驳回</option>
                                    <option value="7">取消订单</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">支付时间</label>
                            <div class="col-sm-10" >
                                <input type="date" class="form-control" name="paytime" value="{$data.paytime}">
                            </div>
                        </div>
                        <input type="hidden" id="id" name="id" value="{$data['id']}">
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit" onclick="add()">保存内容</button>
                                <div class="btn btn-white" id="backs">取消</div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="javascript"}
<script src="ADMIN_JS/content.min.js?v=1.0.0"></script>
<script src="ADMIN_JS/plugins/iCheck/icheck.min.js"></script>
<script>
    var ue = UE.getEditor('editor');
    function add()
    {
        var formData = new FormData();
        var order_number = $("[name='order_number']").val();
        var uid = $("[name='id']").val();
        var commodity_id = $("[name='commodity_id']").val();
        var name = $("[name='name']").val();
        var specification = $("[name='specification']").val();
        var price = $("[name='price']").val();
        var status = $("[name='status']").val();
        var paytime = $("[name='paytime']").val();
        // if(title=='')
        // {
        //     layer.msg('公告标题不能为空')
        //     return false;
        // }
        // if(content=='')
        // {
        //     layer.msg('公告内容不能为空')
        //     return false;
        // }
        formData.append("order_number", order_number);
        formData.append("uid", uid);
        formData.append("commodity_id", commodity_id);
        formData.append("name", name);
        formData.append("specification", specification);
        formData.append("price", price);
        formData.append("status", status);
        formData.append("paytime", paytime);
        var url = '{:url("orders/update")}';
        var loading = layer.msg('正在提交数据，请稍后...', {icon: 16,time:6000});
        $.ajax({
            type:'post',
            url:url,
            data:formData,
            contentType: false,
            processData: false,
            success:function(data){
                layer.close(loading);
                if(data.code==1){
                    layer.msg(data.message,{icon:6,time:1500});
                    setTimeout(function(){window.parent.location.reload();},1000);
                }else{
                    layer.msg(data.message,{icon:5,time:1500});
                }
            }
        })
    }

    $("#backs").click(function(){
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    })

</script>
<!--<script type="text/javascript">-->
<!--//上传图片预览-->
<!--var small_img = document.querySelector('input[name=small_img]');-->
<!--var img = document.querySelector('input[name=img]');-->
<!--small_imgs = document.querySelector('#small_img');-->
<!--imgs = document.querySelector('#img');-->
<!--if (small_img) {-->
<!--small_img.addEventListener('change', function() {-->
<!--var file = this.files[0];-->
<!--var reader = new FileReader();-->
<!--// 监听reader对象的的onload事件，当图片加载完成时，把base64编码賦值给预览图片-->
<!--reader.addEventListener("load", function() {-->
<!--small_imgs.src = reader.result;-->
<!--}, false);-->
<!--// 调用reader.readAsDataURL()方法，把图片转成base64-->
<!--reader.readAsDataURL(file);-->
<!--$("img").eq(0).css("display", "block");-->
<!--}, false);-->
<!--}-->
<!--if(img){-->
<!--img.addEventListener('change', function() {-->
<!--var file = this.files[0];-->
<!--var reader = new FileReader();-->
<!--// 监听reader对象的的onload事件，当图片加载完成时，把base64编码賦值给预览图片-->
<!--reader.addEventListener("load", function() {-->
<!--imgs.src = reader.result;-->
<!--}, false);-->
<!--// 调用reader.readAsDataURL()方法，把图片转成base64-->
<!--reader.readAsDataURL(file);-->
<!--$("img").eq(1).css("display", "block");-->
<!--}, false);-->
<!--}-->

<!--</script>-->
{/block}